package util.android.widgets;

import util.android.form.respuesta.SpinnerInput;
import util.form.respuesta.Friend;

import com.androidutil.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

public class StringSpinner3View 
extends StringView
{
	private final SpinnerInput spinner1;
	private final SpinnerInput spinner2;
	private final SpinnerInput spinner3;
	
	private final TextView etiqueta1;
	private final TextView etiqueta2;
	private final TextView etiqueta3;
	
	public StringSpinner3View(Context context, AttributeSet attrs) {
		super(context, attrs);		
		this.getInput().setSoloLectura(true);
		
		spinner1 = new SpinnerInput((Spinner) View.inflate(getContext(), R.layout.spinner,null));
		spinner2 = new SpinnerInput((Spinner) View.inflate(getContext(), R.layout.spinner,null));
		spinner3 = new SpinnerInput((Spinner) View.inflate(getContext(), R.layout.spinner,null));
		
		etiqueta1 = agregarSpinner(spinner1);
		etiqueta2 = agregarSpinner(spinner2);
		etiqueta3 = agregarSpinner(spinner3);
		
		//spinner1.setInputDependiente(spinner2);
		//spinner2.setInputDependiente(spinner3);
		
		Friend.spinner3View(spinner1, spinner2, spinner3, StringSpinner3View.this);			
	}
		
	private TextView agregarSpinner(SpinnerInput spinnerInput) {
		LinearLayout ly = new LinearLayout(this.getContext()); 		
		ly.setOrientation(LinearLayout.HORIZONTAL);
		
		LinearLayout.LayoutParams params1 = new LayoutParams(
				0, 
				LinearLayout.LayoutParams.WRAP_CONTENT,
				0.5f
				);
		
		TextView tv = (TextView)View.inflate(getContext(), R.layout.text_view,null);
		//tv.setText(this.getResources().getString(stringID));
		ly.addView(tv,params1);
		
		LinearLayout.LayoutParams params2 = new LayoutParams(
				0, 
				LinearLayout.LayoutParams.WRAP_CONTENT,
				1f
				);		
		ly.addView(spinnerInput.getView(),params2);
		
		this.getLayoutRespuesta().addView(ly);
		return tv;
	}

	public SpinnerInput getSpinner1() {
		return spinner1;
	}

	public SpinnerInput getSpinner2() {
		return spinner2;
	}

	public SpinnerInput getSpinner3() {
		return spinner3;
	}

	public TextView getEtiqueta1() {
		return etiqueta1;
	}

	public TextView getEtiqueta2() {
		return etiqueta2;
	}

	public TextView getEtiqueta3() {
		return etiqueta3;
	}

	
	
	
		
}
